﻿package xzl.edu.cn.set.people;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.Message;
import java.util.Date;

public class Employee extends Person {
	public Employee(String name, Double salary, int year, int month, int day) {
		super(name);
		this.salary = salary;
		this.hireday.setYear(year);
		this.hireday.setMonth(month);
		this.hireday.setDate(day);
	}

	public double salary;

	public Date hireday = new Date();

	public String getHireDay() {
		return hireday.toString();
	}

	public double getSalary() {
		return salary;
	}

	public String toString() {
		return "Employee [" + "name:" + name + "salary:" + salary + "Day" + getHireDay();
	}

	/**
	 * 重写equals方法
	 */
	public boolean equals(Object obj) {
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		if (salary != other.salary)
			return false;
		if (hireday.getDay() != other.hireday.getDay())
			return false;
		if (hireday.getMonth() != other.hireday.getMonth())
			return false;
		if (hireday.getYear() != other.hireday.getYear())
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	public void getDescription() {
		Logger logger = LogManager.getLogger(Employee.class);
		logger.info(name + ",This is an Employee with the salary of " + salary);
	}
}
